package exception;

/**
 *
 */
public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
//            String str = null;
//            System.out.println(str.length());
//            System.out.println("!!!!");
//            String str = "abc";
//            System.out.println(Integer.parseInt(str));
//            System.out.println("!!!");
            String str = "abc";
            System.out.println(str.charAt(5));
        }
//        catch (NullPointerException e) {
//            System.out.println("出现了空指针,并处理完毕了");
//        }catch (StringIndexOutOfBoundsException e){
//            System.out.println("出现了字符串下标越界异常,并处理完毕了");
//        }
        catch (NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("空指针或下标越界异常");
        }
        catch (Exception e){
            System.out.println("反正出了个错");
        }
        System.out.println("程序结束了");
    }
}
